home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / terms / kermit / b / cketest.ini < prev    next >
Encoding:
Text File  |  1993-03-20  |  2.4 KB  |  127 lines

  1. COMMENT - CKETEST.INI
  2. ;
  3. ; Exercises C-Kermit's programming constructs (see Ch.12, "Using C-Kermit").
  4. ;
  5. echo
  6. echo C-Kermit Programming-Constructs Test
  7. echo
  8. echo If you don't see the message "Proceeding..."
  9. echo on the next line, C-Kermit was not configured for script programming.
  10. check if
  11. echo Proceeding...
  12. echo
  13. if exist ckedemo.ini goto demo
  14. echo Can't find ckedemo.ini file, proceeding with other tests...
  15. goto other
  16.  
  17. :DEMO
  18. take ckedemo.ini
  19. spellnum 0
  20. spellnum 1
  21. spellnum 2
  22. spellnum 3
  23. spellnum 4
  24.  
  25. echo Calculator demo...
  26. calc
  27.  
  28. echo Adding machine demo...
  29. addingmachine
  30.  
  31. echo Recursive sum macro...
  32.  
  33. def sum if not def \%1 return,-  ; Make sure there is an argument
  34.   if not numeric \%1 return,-    ; Make sure argument is numeric
  35.   if not > \%1 0 return,-        ; Make sure argument is positive
  36.   if = \%1 1 return 1,-          ; If argument is 1, the sum is 1
  37.   else return \feval(\%1 + \fexecute(sum \feval(\%1 - 1)))
  38.  
  39. def addemup echo sum of 0..\%1 = \fexec(sum \%1)
  40. addemup 1
  41. addemup 2
  42. addemup 3
  43. addemup 4
  44. addemup 5
  45. addemup 10
  46. addemup 20
  47.  
  48. :LOOP
  49. echo
  50. ask \%1 { Type 3 numbers separated by spaces:  }
  51. if not def \%1 goto other
  52. smallest \%1
  53. goto loop
  54.  
  55. :OTHER                ; Other tests
  56.  
  57. echo WHILE-LOOP TEST...
  58. echo You should see:
  59. echo { 0 1 2 3 4}
  60. def \%a 0
  61. while < \%a 5 { write scr { \%a}, incr \%a }
  62. echo
  63.  
  64. echo NESTED WHILE-LOOP TEST...
  65. echo You should see:
  66. echo { 0:0 0:1 0:2 1:0 1:1 1:2 2:0 2:1 2:2}
  67. def \%a 0
  68. while < \%a 3 {-
  69.   def \%b 0,-
  70.   while < \%b 3 {-
  71.     write scr { \%a:\%b},-
  72.     incr \%b,-
  73.   },-
  74.   incr \%a -
  75. }
  76. echo
  77.  
  78. echo FOR-LOOP INSIDE WHILE-LOOP
  79. echo You should see:
  80. echo { 1:1 1:2 1:3 2:1 2:2 2:3 3:1 3:2 3:3}
  81. def \%a 1
  82. while < \%a 4 { -
  83.   for %i 1 3 1 { write scr { \%a:\%i} },-
  84.   inc \%a -
  85. }
  86. echo
  87.  
  88. echo WHILE-LOOP INSIDE FOR-LOOP
  89. echo You should see:
  90. echo { 1:1 1:2 1:3 2:1 2:2 2:3 3:1 3:2 3:3}
  91. for \%i 1 3 1 {-
  92.   def \%a 1,-
  93.   while < \%a 4 {-
  94.     writ scr { \%i:\%a},-
  95.     incr \%a -
  96.   }-
  97. }
  98. echo
  99.  
  100. echo NESTED FOR LOOP TEST
  101. echo You should see:
  102. echo { 1:1 1:2 1:3 2:2 2:3 3:3}
  103. for \%i 1 3 1 {-
  104.   for \%j \%i 3 1 {-
  105.     write scr { \%i:\%j} -
  106.   }-
  107. }
  108. echo
  109.  
  110. echo NESTED FOR/WHILE/BREAK/CONTINUE TEST 
  111. echo You should see:
  112. echo { 1:1 1:3 3:1 3:3}
  113. for \%i 1 4 1 { -
  114.   if = \%i 2 continue,-
  115.   else if = \%i 4 break,-
  116.   asg \%j 0,-
  117.   while < \%j 4 { -
  118.     incr \%j,-
  119.     if = \%j 2 continue,-
  120.     else if = \%j 4 break,-
  121.     write screen { \%i:\%j} -
  122.   },-
  123. }
  124. echo
  125. echo End of \v(cmdfile)
  126. echo
  127.